from django.db import models
from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
    sex = models.CharField(max_length=2, default='', verbose_name="性别")
    ad = models.CharField(max_length=256, blank=True, verbose_name="推广")
    push_url = models.URLField(max_length=256, blank=True, verbose_name="百度PUSH")
    article_number = models.IntegerField(default=0, verbose_name="文章数量")
    nick_name = models.CharField(max_length=2, default="令狐冲", verbose_name="昵称")
    openid = models.CharField(max_length=64, default="", blank=True, verbose_name="授权ID")
    money = models.DecimalField(default=0, max_digits=5, decimal_places=2, verbose_name="余额")

    class Meta:
        verbose_name = "作者"
        verbose_name_plural = "作者详情表"

    def __repr__(self):
        return '%s,%s,%s' % (self.pk, self.article_number, self.money)

    def __str__(self):
        return self.username
